import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

class CommonDialog extends StatefulWidget {
  const CommonDialog({Key? key}) : super(key: key);

  @override
  _CommonDialogState createState() => _CommonDialogState();
}

class _CommonDialogState extends State<CommonDialog> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("普通弹框"),
      ),
      body: Center(
          child: Column(
        children: [
          TextButton(
            onPressed: () {
              //material 包中自带方法
              showDialog(
                  context: context,
                  barrierLabel: "什么东东......",
                  barrierColor: Colors.grey,
                  builder: (context) {
                    return UnconstrainedBox(
                        child: Container(
                            decoration: BoxDecoration(
                              border: Border.all(color: Colors.red),
                              color: Colors.white,
                            ),
                            child: Text(
                              "this is dialog",
                              style: TextStyle(decoration: TextDecoration.none, color: Colors.black, fontSize: 19.sp),
                            )));
                  });
            },
            child: Text("弹框"),
          ),
          Divider(),
          TextButton(
            onPressed: () {
              //material 包中自带方法
              showDialog(
                  context: context,
                  barrierColor: Colors.grey,
                  builder: (contxt) {
                    return SimpleDialog(
                      title: new Text('选择'),
                      children: <Widget>[
                        new SimpleDialogOption(
                          child: new Text('选项 1'),
                          onPressed: () {
                            Navigator.of(context).pop();
                          },
                        ),
                        new SimpleDialogOption(
                          child: new Text('选项 2'),
                          onPressed: () {
                            Navigator.of(context).pop();
                          },
                        ),
                      ],
                    );
                  });
            },
            child: Text("简单弹框"),
          ),
        ],
      )),
    );
  }
}
